home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / Apple Shared Library Manager / ASLM Examples / Sample Apps / CSample / Sources / Sample.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-19  |  6.6 KB  |  155 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        Sample.h
  3.  
  4.     Contains:    Declarations for the CSample application that are need by both the
  5.                 application and Rez.
  6.  
  7.     Copyright:    © 1993-1994 by Apple Computer, Inc., all rights reserved.
  8.  
  9. */
  10.  
  11.  
  12. /*    These #defines correspond to values defined in the Pascal source code.
  13.     Sample.c and Sample.r include this file. */
  14.  
  15. /*    Determining an application's minimum size to request from MultiFinder depends
  16.     on many things, each of which can be unique to an application's function,
  17.     the anticipated environment, the developer's attitude of what constitutes
  18.     reasonable functionality and performance, etc. Here is a list of some things to
  19.     consider when determining the minimum size (and preferred size) for your
  20.     application. The list is pretty much in order of importance, but by no means
  21.     complete.
  22.     
  23.     1.    What is the minimum size needed to give almost 100 percent assurance
  24.         that the application won't crash because it ran out of memory? This
  25.         includes not only things that you do have direct control over such as
  26.         checking for NIL handles and pointers, but also things that some
  27.         feel are not so much under their control such as QuickDraw and the
  28.         Segment Loader.
  29.         
  30.     2.    What kind of performance can a user expect from the application when
  31.         it is running in the minimum memory configuration? Performance includes
  32.         not only speed in handling data, but also things like how many documents
  33.         can be opened, etc.
  34.         
  35.     3.    What are the typical sizes of scraps [is a boy dog] that a user might
  36.         wish to work with when lauching or switching to your application? If
  37.         the amount of memory is too small, the scrap may get lost [will have
  38.         to be shot]. This can be quite frustrating to the user.
  39.         
  40.     4.    The previous items have concentrated on topics that tend to cause an
  41.         increase in the minimum size to request from MultiFinder. On the flip
  42.         side, however, should be the consideration of what environments the
  43.         application may be running in. There may be a high probability that
  44.         many users with relatively small memory configurations will want to
  45.         avail themselves of your application. Or, many users might want to use it
  46.         while several other, possibly related/complementary applications are
  47.         running. If that is the case, it would be helpful to have a fairly
  48.         small minimum size.
  49.     
  50.     So, what did we decide on Sample? First, Sample has little risk of
  51.     running out of memory once it starts. Second, performance isn't much
  52.     of an issue since it doesn't do much and multiple windows are not
  53.     allowed. Third, there are no edit operations in Sample itself, so we
  54.     just want to provide enough space for a reasonable scrap to survive
  55.     between desk accessory launches. Lastly, Sample should intrude as little
  56.     as possible, so the effort should be towards making it as small as possible.
  57.     We looked at some heap dumps while the application was running under
  58.     various partition sizes. With a size of 23K, there was approximately
  59.     8-9K free, which is a good 'slop' factor in an application like this
  60.     which doesn't do much, but where we'd still like the scrap to survive
  61.     most of the time. */
  62.  
  63. #define kMinSize    23                /* application's minimum size (in K) */
  64.  
  65. /*    We made the preferred size bigger than the minimum size by 12K, so that
  66.     there would be even more room for the scrap, FKEYs, etc. */
  67.  
  68. #define kPrefSize    35                /* application's preferred size (in K) */
  69.  
  70. #define    rMenuBar    128                /* application's menu bar */
  71. #define    rAboutAlert    128                /* about alert */
  72. #define    rUserAlert    129                /* error user alert */
  73.  
  74. /* kSysEnvironsVersion is passed to SysEnvirons to tell it which version of the
  75.    SysEnvRec we understand. */
  76.  
  77. #define    kSysEnvironsVersion        1
  78.  
  79. /* kOSEvent is the event number of the suspend/resume and mouse-moved events sent
  80.    by MultiFinder. Once we determine that an event is an osEvent, we look at the
  81.    high byte of the message sent to determine which kind it is. To differentiate
  82.    suspend and resume events we check the resumeMask bit. */
  83.  
  84. #define    kOSEvent                app4Evt    /* event used by MultiFinder */
  85. #define    kSuspendResumeMessage    1        /* high byte of suspend/resume event message */
  86. #define    kResumeMask                1        /* bit of message field for resume vs. suspend */
  87. #define    kMouseMovedMessage        0xFA    /* high byte of mouse-moved event message */
  88. #define    kNoEvents                0        /* no events mask */
  89.  
  90. /* The following constants are used to identify menus and their items. The menu IDs
  91.    have an "m" prefix and the item numbers within each menu have an "i" prefix. */
  92.  
  93. #define    mApple                    128        /* Apple menu */
  94. #define    iAbout                    1
  95.  
  96. #define    mFile                    129        /* File menu */
  97. #define    iNew                    1
  98. #define    iClose                    4
  99. #define    iQuit                    12
  100.  
  101. #define    mEdit                    130        /* Edit menu */
  102. #define    iUndo                    1
  103. #define    iCut                    3
  104. #define    iCopy                    4
  105. #define    iPaste                    5
  106. #define    iClear                    6
  107.  
  108. /*    kTopLeft - This is for positioning the Disk Initialization dialogs. */
  109.  
  110. #define kDITop                    0x0050
  111. #define kDILeft                    0x0070
  112.  
  113. /*    kMinHeap - This is the minimum result from the following
  114.     equation:
  115.         
  116.         ORD(GetApplLimit) - ORD(ApplicationZone)
  117.         
  118.     for the application to run. It will insure that enough memory will
  119.     be around for reasonable-sized scraps, FKEYs, etc. to exist with the
  120.     application, and still give the application some 'breathing room'.
  121.     To derive this number, we ran under a MultiFinder partition that was
  122.     our requested minimum size, as given in the 'SIZE' resource. */
  123.      
  124. #define kMinHeap                21 * 1024
  125.     
  126. /*    kMinSpace - This is the minimum result from PurgeSpace, when called
  127.     at initialization time, for the application to run. This number acts
  128.     as a double-check to insure that there really is enough memory for the
  129.     application to run, including what has been taken up already by
  130.     pre-loaded resources, the scrap, code, and other sundry memory blocks. */
  131.      
  132. #define kMinSpace                8 * 1024
  133.  
  134. /* kExtremeNeg and kExtremePos are used to set up wide open rectangles and regions. */
  135.  
  136. #define kExtremeNeg                -32768
  137. #define kExtremePos                32767 - 1 /* required to address an old region bug */
  138.  
  139. /* these #defines are used to set enable/disable flags of a menu */
  140.  
  141. #define AllItems    0b1111111111111111111111111111111    /* 31 flags */
  142. #define NoItems        0b0000000000000000000000000000000
  143. #define MenuItem1    0b0000000000000000000000000000001
  144. #define MenuItem2    0b0000000000000000000000000000010
  145. #define MenuItem3    0b0000000000000000000000000000100
  146. #define MenuItem4    0b0000000000000000000000000001000
  147. #define MenuItem5    0b0000000000000000000000000010000
  148. #define MenuItem6    0b0000000000000000000000000100000
  149. #define MenuItem7    0b0000000000000000000000001000000
  150. #define MenuItem8    0b0000000000000000000000010000000
  151. #define MenuItem9    0b0000000000000000000000100000000
  152. #define MenuItem10    0b0000000000000000000001000000000
  153. #define MenuItem11    0b0000000000000000000010000000000
  154. #define MenuItem12    0b0000000000000000000100000000000
  155.